<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <meta name = "format-detection" content = "telephone=no">
    <title>地址列表</title>
    <link rel="stylesheet" href="__PUBLIC__/Home/css/address.css">
    <include file="Public/common_js"/>
</head>
<body style="background:#e8eded;">

<style>
    .empty-box {
        text-align: center;
        height: 100%;
        padding-top: 2rem;
    }
    .empty-box img {
        width: 1.73rem;
        height: 2.92rem;
    }
    .empty-box p {
        font-size: .3rem;
        color: #5c6160;
        padding: 0 2rem;
    }
</style>

<empty name="addList">
<div class="empty-box" >
    <img src="__PUBLIC__/Home/images/iconEmpty.png" alt="">
    <p>请先添加收货地址</p>
</div>
</empty>
<notempty name="addList">
<div class="warp">
    <div class="address-list">
        <ul>
            <volist name="addList" id="addr">
                <li class="addr-one-box">
                    <div class="top" style="padding-left: .1rem;" data-id="{$addr.addr_id}">
                       <!-- <a href="javascript:void(0);" class="choice <if condition='$addr[def_addr] eq 1 '> active </if>"></a>-->
                        <p class="clearfix"><span class="fl">{$addr.name}</span><span class="fr">{$addr.mobile}</span></p>
                        <p class="text-hide"><if condition="$addr.def_addr  eq 1 "><label>默认地址</label></if>{$addr.area}{$addr.addr}</p>
                    </div>

                    <div class="bot">

                       <!-- <a>使用该地址 </a>-->

                        <a href="javascript:void(0);" onclick="window.location.href='{:url(\'Address/addAddress\')}?addrId={$addr[addr_id]}'" class="edit">编辑</a>
                        <a href="javascript:void(0);" onclick="delAddress(this, {$addr[addr_id]})" class="delete">删除</a>
                    </div>
                </li>
            </volist>
        </ul>
    </div>
</div>
    </notempty>
<div class="address-new"><a href="{:url('Address/addressModify')}" class="btn btn-block ">+新建地址</a></div>
<script type="text/javascript">
    var _isDeleting = false;
    function delAddress(o, addrId){
        if(_isDeleting){
            return;
        }
        _isDeleting = true;
        _global.promote.loadPopup("正在处理中...");
        $.ajax({
            type: "POST",
            url: "/Home/Address/deleteAddr",
            data: {"addrId" : addrId},
            dataType: "json",
            success: function (rs) {
                _global.promote.removeLoad();
                _global.promote.alertPopup(rs.msg);
                if(rs.status){
                    $(o).parents(".addr-one-box").remove();
                }
                _isDeleting = false;
            },
            error: function () {
                _global.promote.removeLoad();
                _global.promote.alertPopup('服务器异常，请稍后重试！');
                _isDeleting = false;
            }
        });
    }
	require(['addressList']);
</script>
</body>
</html>